home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / standard / sync.z / sync
Encoding:
Text File  |  2002-10-03  |  8.3 KB  |  199 lines

  1. SYNC(3C)                                              Last changed: 1-13-99
  2.  
  3.  
  4. NNAAMMEE
  5.      ssyynncc, ____ffeettcchh__aanndd__aadddd, ____ffeettcchh__aanndd__ssuubb, ____ffeettcchh__aanndd__oorr,
  6.      ____ffeettcchh__aanndd__aanndd, ____ffeettcchh__aanndd__xxoorr, ____ffeettcchh__aanndd__nnaanndd, ____aadddd__aanndd__ffeettcchh,
  7.      ____ssuubb__aanndd__ffeettcchh, ____oorr__aanndd__ffeettcchh, ____aanndd__aanndd__ffeettcchh, ____xxoorr__aanndd__ffeettcchh,
  8.      ____nnaanndd__aanndd__ffeettcchh, ____ccoommppaarree__aanndd__sswwaapp, ____ssyynncchhrroonniizzee,
  9.      ____lloocckk__tteesstt__aanndd__sseett, ____lloocckk__aaccqquuiirree, ____lloocckk__rreelleeaassee - C
  10.      synchronization primitives for multiprocessing
  11.  
  12. SSYYNNOOPPSSIISS
  13.      See summaries in DESCRIPTION
  14.  
  15. IIMMPPLLEEMMEENNTTAATTIIOONN
  16.      IRIX systems
  17.  
  18. DDEESSCCRRIIPPTTIIOONN
  19.      The intrinsics described here provide a variety of primitive
  20.      synchronization operations.  Besides performing the particular
  21.      synchronization operation, each of these intrinsics has two key
  22.      properties:
  23.  
  24.      1. The function performed is guaranteed to be atomic (typically
  25.         achieved by implementing the operation using a sequence of load-
  26.         linked/store-conditional instructions in a loop).
  27.  
  28.      2. Associated with each instrinsic are certain memory barrier
  29.         properties that restrict the movement of memory references to
  30.         visible data across the intrinsic operation (by either the compiler
  31.         or the processor).
  32.  
  33.         A visible memory reference is a reference to a data object
  34.         potentially accessible by another thread executing in the same
  35.         shared address space. A visible data object may be one of the
  36.         following:
  37.  
  38.         *  C/C++ global data
  39.  
  40.         *  Fortran COMMON data
  41.  
  42.         *  Data declared _e_x_t_e_r_n
  43.  
  44.         *  Volatile data
  45.  
  46.         *  Static data (either file-scope or function-scope)
  47.  
  48.         *  Data accessible via function parameters
  49.  
  50.         *  Automatic data (local-scope) that has had its address taken and
  51.            assigned to some object which is visible (recursively)
  52.  
  53.      The memory barrier semantics of an intrinsic may be one of the
  54.      following three types:
  55.  
  56.      aaccqquuiirree bbaarrrriieerr
  57.           Disallows the movement of memory references to visible data from
  58.           after the intrinsic (in program order) to before the intrinsic
  59.           (this behavior is desirable at lock-acquire operations, hence the
  60.           name).
  61.  
  62.      rreelleeaassee bbaarrrriieerr
  63.           Disallows the movement of memory references to visible data from
  64.           before the intrinsic (in program order) to after the intrinsic
  65.           (this behavior is desirable at lock-release operations, hence the
  66.           name).
  67.  
  68.      ffuullll bbaarrrriieerr
  69.           disallows the movement of memory references to visible data past
  70.           the intrinsic (in either direction), and is thus both an acquire
  71.           and a release barrier. A barrier only restricts the movement of
  72.           memory references to visible data across the intrinsic operation:
  73.           between synchronization operations (or in their absence), memory
  74.           references to visible data may be freely reordered subject to the
  75.           usual data-dependence constraints.
  76.  
  77.      CCaauuttiioonn:: Conditional execution of a synchronization intrinsic (such as
  78.      within a iiff or a wwhhiillee statement) does not prevent the movement of
  79.      memory references to visible data past the overall iiff or wwhhiillee
  80.      construct.
  81.  
  82.    AAttoommiicc ffeettcchh--aanndd--oopp OOppeerraattiioonnss
  83.           "type __fetch_and_add (type* ptr, type value, ...)"
  84.  
  85.           "type __fetch_and_sub (type* ptr, type value, ...)"
  86.  
  87.           "type __fetch_and_or  (type* ptr, type value, ...)"
  88.  
  89.           "type __fetch_and_and (type* ptr, type value, ...)"
  90.  
  91.           "type __fetch_and_xor (type* ptr, type value, ...)"
  92.  
  93.           "type __fetch_and_nand(type* ptr, type value, ...)"
  94.  
  95.      Where ttyyppee may be one of iinntt, lloonngg, lloonngg lloonngg, uunnssiiggnneedd iinntt, uunnssiiggnneedd
  96.      lloonngg, or uunnssiiggnneedd lloonngg lloonngg.  The ellipses (...) refers to an optional
  97.      list of variables protected by the memory barrier.
  98.  
  99.      Behavior:
  100.  
  101.      * Atomically performs the specified operation with the given value on
  102.        **ppttrr, and returns the old value of **ppttrr, as in the following
  103.        example:
  104.  
  105.           { tmp = *ptr; *ptr <op>= value; return tmp; }
  106.  
  107.      * Full barrier.
  108.  
  109.    AAttoommiicc oopp--aanndd--ffeettcchh OOppeerraattiioonnss
  110.           "type __add_and_fetch (type* ptr, type value, ...)"
  111.  
  112.           "type __sub_and_fetch (type* ptr, type value, ...)"
  113.  
  114.           "type __or_and_fetch  (type* ptr, type value, ...)"
  115.  
  116.           "type __and_and_fetch (type* ptr, type value, ...)"
  117.  
  118.           "type __xor_and_fetch (type* ptr, type value, ...)"
  119.  
  120.           "type __nand_and_fetch(type* ptr, type value, ...)"
  121.  
  122.      Where ttyyppee may be one of iinntt, lloonngg, lloonngg lloonngg, uunnssiiggnneedd iinntt, uunnssiiggnneedd
  123.      lloonngg, or uunnssiiggnneedd lloonngg lloonngg.  The ellipses (...) refers to an optional
  124.      list of variables protected by the memory barrier.
  125.  
  126.      Behavior:
  127.  
  128.      * Atomically performs the specified operation with the given value on
  129.        *ptr, and returns the new value of *ptr. (i.e.)
  130.  
  131.           { *ptr <op>= value; return *ptr; }
  132.  
  133.      * Full barrier.
  134.  
  135.    AAttoommiicc ccoommppaarree--aanndd--sswwaapp OOppeerraattiioonn
  136.     "int __compare_and_swap (type* ptr, type oldvalue, type newvalue, ...)"
  137.  
  138.      Where ttyyppee may be one of iinntt, lloonngg, lloonngg lloonngg, uunnssiiggnneedd iinntt, uunnssiiggnneedd
  139.      lloonngg, or uunnssiiggnneedd lloonngg lloonngg.  The ellipses (...) refers to an optional
  140.      list of variables protected by the memory barrier.
  141.  
  142.      Behavior:
  143.  
  144.      * Atomically do the following: compare *ptr to oldvalue. If equal,
  145.        store the new value and return 1, otherwise return 0. (i.e.)
  146.  
  147.           if (*ptr != oldvalue) return 0;
  148.  
  149.           else {
  150.  
  151.                   *ptr = newvalue;
  152.  
  153.                   return 1;
  154.           }
  155.  
  156.      * Full barrier.
  157.  
  158.    AAttoommiicc ssyynncchhrroonniizzee OOppeerraattiioonn
  159.           "__synchronize (...)"
  160.  
  161.      The ellipses (...) refers to an optional list of variables protected
  162.      by the memory barrier.
  163.  
  164.      Behavior:
  165.  
  166.      * Full barrier
  167.  
  168.    AAttoommiicc lloocckk--tteesstt--aanndd--sseett OOppeerraattiioonn
  169.           ""ttyyppee ____lloocckk__tteesstt__aanndd__sseett ((ttyyppee** ppttrr,, ttyyppee vvaalluuee,, ......))""
  170.  
  171.      Where ttyyppee may be one of iinntt, lloonngg, lloonngg lloonngg, uunnssiiggnneedd iinntt, uunnssiiggnneedd
  172.      lloonngg, or uunnssiiggnneedd lloonngg lloonngg.  The ellipses (...) refers to an optional
  173.      list of variables protected by the memory barrier.
  174.  
  175.      Behavior:
  176.  
  177.      * Atomically store the supplied value in *ptr and return the old value
  178.        of *ptr. (i.e.)
  179.  
  180.           { tmp = *ptr; *ptr = value; return tmp; }
  181.  
  182.      * Acquire barrier.
  183.  
  184.    AAttoommiicc lloocckk__rreelleeaassee OOppeerraattiioonn
  185.           "void __lock_release (type* ptr, ...)"
  186.  
  187.      Where ttyyppee may be one of iinntt, lloonngg, lloonngg lloonngg, uunnssiiggnneedd iinntt, uunnssiiggnneedd
  188.      lloonngg, or uunnssiiggnneedd lloonngg lloonngg.  The ellipses (...) refers to an optional
  189.      list of variables protected by the memory barrier.
  190.  
  191.      Behavior:
  192.  
  193.      * Set *ptr to 0.  (i.e.) { *ptr = 0 }
  194.  
  195.      * Release barrier.
  196.  
  197. SSEEEE AALLSSOO
  198.      This man page is available only online.
  199.